<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>生活加盟商列表</title>
    <link rel="stylesheet" type="text/css" th:href="@{/manager/easyui/themes/default/easyui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/manager/easyui/themes/icon.css}">
    <script type="text/javascript" th:src="@{/manager/easyui/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/manager/easyui/jquery.easyui.min.js}"></script>
	  <script type="text/javascript">
	   $(function(){
         //初始化生活加盟商列表
	       $('#commpanylist').datagrid({  
    				title:'生活加盟商列表',  
    				iconCls:'icon-save',
                    queryParams:{
                        "name": null,
                        "phone": null,
                        "memberId": -1,
                        "flag": -1,
                        "type": 1
                    },
                    url:"/manager/serverCompany/findAll",
    				columns:[
                        [
              					       {field:'name',title:'服务商名称',width:200,align:'center'},  
              					       {field:'address',title:'公司地址',width:200,align:'center',formatter:function(val,row){
                                             var link = "<a href='/manager/map/showMap?gps=" + row.gps + "' target='view_window'>" + val + "</a>";
                                             return link;
                               }},
              					       {field:'linkman',title:'联系人',width:100,align:'center'},
                               {field:'phone',title:'公司电话',width:100,align:'center'},
                               {field:'zzh',title:'平台子账号',width:100,align:'center',formatter:function (val,row){
                                        return row.childCount;
                                   }},
                               {field:'commpanylevel',title:'服务商等级',width:100,align:'center',formatter:function (val,row){
                                        if(row.level == null){
                                            return "-";
                                        }else{
                                            return row.level;
                                        }
                                   }},
                               {field:'joindate',title:'入驻时间',width:100,align:'center',formatter:function (val,row){
                                       var createdate = new Date(val);
                                       var year = createdate.getFullYear();
                                       var month = ('' + (createdate.getMonth() + 1)).slice(-2);
                                       var day = ('' + createdate.getDate()).slice(-2);
                                       return year + '-' + month + '-' + day;
                                   }},
                               {field:'flag',title:'状态',width:100,align:'center',formatter:function (val,row){
                                       return val === 1?"启用":"禁用";
                                   }},
                               {field:'cz',title:'操作',width:200,align:'center',formatter:function(val,row){
                                     return "<a href='javascript:showDg();'>查看</a>";
                               }}
                        ]
                    ],
        				toolbar: "#tooldiv",  
        				pagination: true,
        				singleSelect:true
    			});

         //初始化子账号列表初始化
        $('#subaccountlist').datagrid({
              queryParams:{
                "id": function() {
                    if(selectedRowId){
                        return selectedRowId;
                    }else{
                        return -1;
                    }
                } // 使用函数来动态获取值
              },
              url:"/manager/user/findByCompanyId",
              columns:[
                  [
                                 {field:'name',title:'姓名',width:100,align:'center'},  
                                 {field:'phone',title:'电话',width:100,align:'center'},  
                                 {field:'wechat',title:'微信号',width:100,align:'center'},
                                 {field:'qq',title:'QQ',width:100,align:'center'},
                                 {field:'flag',title:'状态',width:100,align:'center',formatter:function (val,row){
                                     return val === 1?"启用":"禁用";
                                     }},
                                 {field:'cz',title:'操作',width:100,align:'center',formatter:function(val,row){
                                     return "<a href='javascript:showConfirm();'>解除关联</a>";
                               }}
                          ]
              ],
              pagination: false,
              singleSelect:true
      });


          
          //初始化修改窗口  
         $('#dg').dialog({
    			    title: '服务商详情',
    			    width: 700,
    			    height: 700,
    			    closed: true,
    			    cache: false,
    			    modal: true,
    			    iconCls: 'icon-save'
    			});

         $("#editdg").dialog({
              title: '服务商修改',
              width: 700,
              height: 700,
              closed: true,
              cache: false,
              modal: true,
              iconCls: 'icon-save',
              buttons: [{
                 text:'提交',
                 iconCls:'icon-ok',
                 handler:function(){
                     if ($("#editdg input.easyui-textbox:eq(0)").textbox("getValue").trim() === "" || $("#editdg input.easyui-textbox:eq(1)").textbox("getValue").trim() === "" || $("#editdg input.easyui-textbox:eq(2)").textbox("getValue").trim() === "" || $("#editdg input.easyui-textbox:eq(3)").textbox("getValue").trim() === "" || $("#editdg input.easyui-textbox:eq(4)").textbox("getValue").trim() === "" || $("#editdg input.easyui-textbox:eq(5)").textbox("getValue").trim() === "" || $("#editdg input.easyui-textbox:eq(6)").textbox("getValue").trim() === "" || $('#editdg textarea').val().trim() === "" || files.length === 0) {
                         alert("修改的内容不能为空!");
                     }else {
                         var selectedRow = $("#commpanylist").datagrid('getSelected');
                         var uploadFile = new FormData($("#formdata")[0]);
                         var existingImages = [];
                         var newFiles = [];
                         files.forEach(function(item) {
                             if (item instanceof File) {
                                 newFiles.push(item); // 新上传文件
                             } else {
                                 existingImages.push(item); // 服务器已有图片URL
                             }
                         });
                         newFiles.forEach(function(file) {
                             uploadFile.append("imgs", file); // 只传File对象
                         });
                         uploadFile.append("existingImages", existingImages.join(','));
                         uploadFile.append("id", selectedRow.id);
                         uploadFile.append("name", $("#editdg input.easyui-textbox:eq(0)").textbox("getValue"));
                         uploadFile.append("address", $("#editdg input.easyui-textbox:eq(1)").textbox("getValue"));
                         uploadFile.append("phone", $("#editdg input.easyui-textbox:eq(2)").textbox("getValue"));
                         uploadFile.append("linkman", $("#editdg input.easyui-textbox:eq(3)").textbox("getValue"));
                         uploadFile.append("scale", $("#editdg input.easyui-textbox:eq(4)").textbox("getValue"));
                         uploadFile.append("type", $("#editdg select.easyui-combobox").combobox('getValue'));
                         uploadFile.append("createdate", $("#editdg input.easyui-textbox:eq(5)").textbox("getValue"));
                         uploadFile.append("gps", $("#editdg input.easyui-textbox:eq(6)").textbox("getValue"));
                         uploadFile.append("info", $('#editdg textarea').val());
                         $.ajax({
                             dataType: "json",
                             type: "post",
                             url: "/manager/serverCompany/modifyInfo",
                             data: uploadFile,
                             contentType: false,
                             processData: false,
                             success: function (result) {
                                 if (result.status == 200) {
                                     alert(result.msg);
                                     $('#commpanylist').datagrid("reload")
                                     $('#editdg').dialog('close');
                                 }
                             },
                             error: function (xhr, status, error) {
                                 alert("请求失败: " + xhr.responseText); // 处理 AJAX 请求错误
                             }
                         });
                     }
                 }
             },{
                 text:'关闭',
                 handler:function(){
                     $('#editdg').dialog("close");
                 }
             }]
          });


         $("#subaccountdg").dialog({
              title: '子账户展示',
              width: 800,
              height: 600,
              closed: true,
              cache: false,
              modal: true,
              iconCls: 'icon-save'
          });

         //初始化查询按钮
         $("#submit_search").linkbutton({ iconCls: 'icon-search', plain: true })
            .click(function () {
                const tooldiv = document.getElementById('tooldiv');
                const inputs = tooldiv.querySelectorAll('input[type="text"]');
                const select = tooldiv.querySelectorAll('select');
                var pager = $('#commpanylist').datagrid('getPager');
                // 直接设置数据网格的查询参数
                var queryParams = {
                    "page": 1,
                    "name": inputs[0].value,
                    "phone": inputs[1].value,
                    "memberId": select[0].value,
                    "flag": select[1].value,
                    "type": 1
                };
                $('#commpanylist').datagrid('options').queryParams = queryParams;
                $('#commpanylist').datagrid('reload');
                pager.pagination('refresh', {
                    pageNumber: 1
                });
            });
            
	   });

        //查询弹出方法
       function showDg(){
           var selectedRow = $('#commpanylist').datagrid('getSelected');
           $.ajax({
               dataType: "json",
               url: "/manager/serverCompany/findById",
               data: {"id":selectedRow.id},
               success: function (result) {
                   if (result.status == 200) {
                       $('#dg').dialog("open");
                       var createdate = new Date(result.data.createdate);
                       var year = createdate.getFullYear();
                       var month = ('' + (createdate.getMonth() + 1)).slice(-2);
                       var day = ('' + createdate.getDate()).slice(-2);
                       var formattedDate = year + '-' + month + '-' + day;
                       var type = result.data.type === 1?"生活":"商务";
                       $("#dg input.easyui-textbox:eq(0)").textbox("setValue", result.data.name);
                       $("#dg input.easyui-textbox:eq(1)").textbox("setValue", result.data.address);
                       $("#dg input.easyui-textbox:eq(2)").textbox("setValue", result.data.phone);
                       $("#dg input.easyui-textbox:eq(3)").textbox("setValue", result.data.linkman);
                       $("#dg input.easyui-textbox:eq(4)").textbox("setValue", result.data.scale);
                       $("#dg input.easyui-textbox:eq(5)").textbox("setValue", result.data.childCount);
                       $("#dg input.easyui-textbox:eq(6)").textbox("setValue", type);
                       $("#dg input.easyui-textbox:eq(7)").textbox("setValue", formattedDate);
                       $('#dg textarea').val(result.data.info);
                       $('#dg .imgtab').empty();
                       (result.data.imageUrls || []).forEach(function(imageUrl) {
                           var img = $('<img>').attr('src', imageUrl).attr('alt', '').css({
                               'width': '100px',
                               'height': '100px'
                           });
                           $('#dg .imgtab').append(img);
                       });
                   }
               },
               error: function (xhr, status, error) {
                   alert("请求失败: " + xhr.responseText); // 处理 AJAX 请求错误
               }
           });
       }

       //打开修改界面方法
       function openeditdg(){
           var selectedRow = $('#commpanylist').datagrid('getSelected');
           if(selectedRow){
               $.ajax({
                   dataType: "json",
                   url: "/manager/serverCompany/findCompany",
                   data: {"id":selectedRow.id},
                   success: function (result) {
                       if (result.status == 200) {
                           $('#editdg').dialog('open');
                           var createdate = new Date(result.data.createdate);
                           var year = createdate.getFullYear();
                           var month = ('' + (createdate.getMonth() + 1)).slice(-2);
                           var day = ('' + createdate.getDate()).slice(-2);
                           var formattedDate = year + '-' + month + '-' + day;
                           $("#editdg input.easyui-textbox:eq(0)").textbox("setValue", result.data.name);
                           $("#editdg input.easyui-textbox:eq(1)").textbox("setValue", result.data.address);
                           $("#editdg input.easyui-textbox:eq(2)").textbox("setValue", result.data.phone);
                           $("#editdg input.easyui-textbox:eq(3)").textbox("setValue", result.data.linkman);
                           $("#editdg input.easyui-textbox:eq(4)").textbox("setValue", result.data.scale);
                           $("#editdg input.easyui-textbox:eq(5)").textbox("setValue", formattedDate);
                           $("#editdg input.easyui-textbox:eq(6)").textbox("setValue", result.data.gps);
                           $('#editdg textarea').val(result.data.info);
                           $("#editdg select.easyui-combobox").combobox('setValue', result.data.type);
                           var form = document.getElementById('formdata');
                           form.reset();
                           var gallery = document.getElementById('gallery');
                           gallery.innerHTML = '';
                           files = [];
                           (result.data.imageUrls || []).forEach(function(imageUrl) {
                               files.push(imageUrl)
                               var box = document.createElement("img");
                               box.setAttribute("src", imageUrl);
                               box.className = 'img';

                               var imgBox = document.createElement("div");
                               imgBox.style.display = 'inline-block';
                               imgBox.className = 'img-item';

                               var deleteIcon = document.createElement("span");
                               deleteIcon.className = 'delete';
                               deleteIcon.innerText = 'x';
                               // 注意：这里不应该使用 file.name 作为 ID，因为文件名可能不唯一
                               // deleteIcon.id = img[i].name; // 移除这行
                               deleteIcon.dataset.filename = imageUrl; // 使用 data-filename 属性代替

                               imgBox.appendChild(deleteIcon);
                               imgBox.appendChild(box);

                               var gallery = document.getElementsByClassName("gallery")[0];
                               gallery.appendChild(imgBox);

                               // 点击 span 事件（这部分代码需要稍作调整以确保正确的上下文）
                               $(deleteIcon).click(deleteFileHandler);
                           });
                       }
                   },
                   error: function (xhr, status, error) {
                       alert("请求失败: " + xhr.responseText); // 处理 AJAX 请求错误
                   }
               });
           }else{
               alert("请选中列表中对应的信息!");
           }
       }

       //对解除关联进行确认
       function showConfirm(){
           var userConfirmed = confirm("确认是否解除关联?");
           if (userConfirmed) {
               // 用户点击了确定按钮
               var selectedRow = $("#subaccountlist").datagrid('getSelected');
               $.ajax({
                   dataType: "json",
                   url: "/manager/user/modifyCompanyId",
                   data: {"id":selectedRow.id},
                   success: function (result) {
                       $('#subaccountlist').datagrid('reload');
                       $('#commpanylist').datagrid('reload');
                   },
                   error: function (xhr, status, error) {
                       alert("请求失败: " + xhr.responseText); // 处理 AJAX 请求错误
                   }
               });
           }
       }

       var selectedRowId;
       //打开子账号展示界面方法
       function opensubaccountdg(){
           var selectedRow = $("#commpanylist").datagrid('getSelected');
           if(selectedRow){
               selectedRowId = selectedRow.id; // 更新全局变量
               $('#subaccountdg').dialog('open');
               // 可能需要刷新datagrid以应用新的queryParams
               $('#subaccountlist').datagrid('reload');
           }else{
               alert("请选中对应的加盟商!");
           }
       }

       //禁用操作
       function disabledStatus(){
           var selectedRow = $("#commpanylist").datagrid('getSelected');
           if(selectedRow){
               var index = $("#commpanylist").datagrid('getRowIndex', selectedRow); // 获取行的索引
               if (selectedRow.flag === 1){
                   $("#commpanylist").datagrid('updateRow', {
                       index: index,
                       row: {
                           flag: 0,
                       }
                   });
                   $.ajax({
                       dataType: "json",
                       url: "/manager/serverCompany/modifyStatus",
                       data: {"id":selectedRow.id,"managerUserId":sessionStorage.getItem("USER_ID")},
                       success: function (result) {

                       },
                       error: function (xhr, status, error) {
                           alert("请求失败: " + xhr.responseText); // 处理 AJAX 请求错误
                       }
                   });
               }
           }

       }

       //启用操作
       function enabledStatus() {
           var selectedRow = $("#commpanylist").datagrid('getSelected');
           if (selectedRow) {
               var index = $("#commpanylist").datagrid('getRowIndex', selectedRow); // 获取行的索引
               if (selectedRow.flag === 0) {
                   $("#commpanylist").datagrid('updateRow', {
                       index: index,
                       row: {
                           flag: 1,
                       }
                   });
                   $.ajax({
                       dataType: "json",
                       url: "/manager/serverCompany/modifyStatus",
                       data: {"id": selectedRow.id},
                       success: function (result) {

                       },
                       error: function (xhr, status, error) {
                           alert("请求失败: " + xhr.responseText); // 处理 AJAX 请求错误
                       }
                   });
               }
           }
       }
	</script>
    <style>
        .gallery .img-item {
            position: relative;
        }

        .gallery .img-item .delete {
            position: absolute;
            display: block;
            width: 20px;
            height: 20px;
            color: #fff;
            background: rgba(0, 0, 0, 0.7);
            line-height: 20px;
            text-align: center;
            border-radius: 50%;
            top: 25px;
            right: 25px;
            cursor: pointer;
        }


        .img {
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
  <div id="tooldiv">
      <input type="text"  placeholder="请输入查询服务商名"/>
      <input type="text"  placeholder="请输入查询服务商电话"/>
      <select>
          <option value="-1">请选服务商等级</option>
          <option value="1">VIP体验</option>
          <option value="2">初级VIP</option>
          <option value="3">中级VIP</option>
          <option value="4">高级VIP</option>
      </select>
      <select>
          <option value="-1">请选状态</option>
          <option value="1">启用</option>
          <option value="0">禁用</option>
      </select>
      <a id="submit_search">搜索</a>
          <a class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="openeditdg()">修改</a>
          <a class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="opensubaccountdg()">子账户维护</a>
          <a class="easyui-linkbutton" data-options="iconCls:'icon-remove'" href="javascript:disabledStatus();">禁用</a>
          <a class="easyui-linkbutton" data-options="iconCls:'icon-add'" href="javascript:enabledStatus();">启用</a>
  </div>
  <table id="commpanylist"></table>
    <!--服务商详情展示界面-->
    <div id="dg">
           <div align="center" style="margin-top: 30px">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%" data-options="label:'服务商名称:'" readonly="true" value="安普惠融资担保有限公司" />
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%" data-options="label:'公司地址:'" readonly="true" value="南京市鼓楼区xxxxxx"/>
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%" data-options="label:'公司电话:'" readonly="true" value="123456123"/>
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'联系人:'" readonly="true" value="谢老板"/>
            </div> 
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'规模:'" readonly="true" value="100人以上"/>
            </div> 
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'平台子账号:'" readonly="true" value="3" />
            </div> 
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'服务商类型:'" readonly="true" value="VIP1"/>
            </div> 
             <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'注册时间:'" readonly="true" value="2021-1-1"/>
            </div> 
            <div style="margin-bottom:20px">
                <textarea cols="80" rows="5" readonly="true" style="border: 0px;">
 百姓网成立于2005年3月，是国内领先的分类信息生态服务商，是中国互联网轻资产模式的典范百姓网致力于创造以分类信息业务为平台、多条垂直业务线布局的生态圈为用户提供涵生活服务、招聘求职、房屋租售、二手车买卖、二手交易、教育培训、同城交友等一站式本地生活服务信息平台，同时为中小微商户建立全方位的精准营销解决方案。
                </textarea>
          </div>
          <div class="imgtab">
              <img src="./images/tx.jpg" alt="" style="width: 100px;height: 100px;">
              <img src="./images/tx.jpg" alt="" style="width: 100px;height: 100px;">
              <img src="./images/tx.jpg" alt="" style="width: 100px;height: 100px;">
              <img src="./images/tx.jpg" alt="" style="width: 100px;height: 100px;">
              <img src="./images/tx.jpg" alt="" style="width: 100px;height: 100px;">

          </div>
      </div>
   </div>
   <!--服务商信息修改界面-->
    <div id="editdg">
           <div align="center" style="margin-top: 30px">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%" data-options="label:'服务商名称:'"  value="" />
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%" data-options="label:'公司地址:'"  value=""/>
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%" data-options="label:'公司电话:'"  value=""/>
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'联系人:'" value=""/>
            </div> 
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'规模:'"  value=""/>
            </div> 
            <div style="margin-bottom:20px">
                <select class="easyui-combobox" name="language" label="服务商类型:" style="width:50%" data-options="multiple:false" >
                    <option value="1">生活</option>
                    <option value="2">商务</option>
                </select>
            </div> 
             <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'注册时间:'"  value=""/>
            </div> 
            <div style="margin-bottom:20px">
                <input class="easyui-textbox"  style="width:50%;" data-options="label:'GPS坐标:'"  value=""/>
            </div> 
            <div style="margin-bottom:20px">
                <textarea cols="80" rows="5"></textarea>
          </div>
          <div style="margin-bottom:20px">
              <form id="formdata" method="post" enctype="multipart/form-data">
                  <div id="upload" class="btn btn-primary">选择图片</div>
                  <div class="gallery" id="gallery"></div>
              </form>
              <input id="file" type="file" multiple style="display: none">
          </div>
      </div>
   </div>
   <!--子账号展示界面-->
    <div id="subaccountdg">
      <table id="subaccountlist"></table>
   </div>
  <script>
      // 创建数组保存图片
      var files = [];
      var id = 0;
      const MAX_FILES = 4; // 最大文件数

      // 选择图片按钮隐藏 input[file]
      $("#upload").click(function() {
          $("#file").trigger("click");
      });

      // 选择图片
      $("#file").change(function() {
          // 获取所有选中的文件
          var selectedFiles = document.getElementById("file").files;
          var currentFileCount = files.length; // 当前已上传的文件数

          // 检查是否超过了最大文件数
          if (selectedFiles.length + currentFileCount > MAX_FILES) {
              alert("最多只能上传四个文件！");
              return; // 阻止进一步处理
          }

          // 遍历选中的文件
          for (var i = 0; i < selectedFiles.length; i++) {
              var file = selectedFiles[i];
              files.push(file); // 把文件存到数组中

              // 获取图片路径并创建图片元素等（这部分代码保持不变）
              var url = URL.createObjectURL(file);
              var box = document.createElement("img");
              box.setAttribute("src", url);
              box.className = 'img';

              var imgBox = document.createElement("div");
              imgBox.style.display = 'inline-block';
              imgBox.className = 'img-item';

              var deleteIcon = document.createElement("span");
              deleteIcon.className = 'delete';
              deleteIcon.innerText = 'x';
              // 注意：这里不应该使用 file.name 作为 ID，因为文件名可能不唯一
              // deleteIcon.id = img[i].name; // 移除这行
              deleteIcon.dataset.filename = file.name; // 使用 data-filename 属性代替

              imgBox.appendChild(deleteIcon);
              imgBox.appendChild(box);

              var gallery = document.getElementsByClassName("gallery")[0];
              gallery.appendChild(imgBox);

              // 点击 span 事件（这部分代码需要稍作调整以确保正确的上下文）
              $(deleteIcon).click(deleteFileHandler);
          }
      });

      // 删除图片事件处理函数
      function deleteFileHandler() {
          var filename = $(this).data('filename'); // 获取对应的文件名或URL
          $(this).parent().remove(); // 移除预览元素

          // 更新files数组：根据类型匹配字符串或File对象
          files = files.filter(function(file) {
              if (file instanceof File) {
                  return file.name !== filename; // 新文件按name比较
              } else {
                  return file !== filename; // 服务器图片按URL字符串比较
              }
          });
      }
      //上传功能
      // $("#uploadImg").click(
      //     function() {
      //         //创建FormData根据form
      //         var uploadFile = new FormData($("#formdata")[0]);
      //         //遍历图片数组把图片添加到FormData中
      //         for (var i = 0; i < files.length; i++) {
      //             uploadFile.append("imgs", files[i]);
      //             alert(files[i].name);
      //         }
      //         if ("undefined" != typeof (uploadFile) && uploadFile != null && uploadFile != "") {
      //             //通过ajax上传
      //             $.ajax({
      //                 url : basePath + "/uplocadImages/uplocadImage.do",
      //                 type : "post",
      //                 data : uploadFile, //把FormData作为参数
      //                 contentType : false, //不设置内容类型
      //                 processData : false, //不处理数据
      //                 success : function(data) {
      //                     if (data) {
      //                         alert("上传成功!");
      //                         window.location.reload();
      //                     } else {
      //                         alert("上传失败!");
      //                     }
      //                 },
      //                 error : function() {
      //                     alert("上传失败！");
      //                 }
      //             });
      //         }
      //     });
  </script>
</body>
</html>